﻿using System.Web.Mvc;
using DevWeb.Biztalk.DeploymentSettings.Data.CodeFirst.Context;

using DevWeb.Biztalk.DeploymentSettings.WebUI.Automapper;
using Microsoft.Practices.Unity;

namespace DevWeb.Biztalk.DeploymentSettings.WebUI.Bootstrapper
{
    public class Bootstrapper
    {
        public static IUnityContainer Initialise()
        {
            var container = BuildUnityContainer();
            var resolver = DependencyResolver.Current;

            DependencyResolver.SetResolver(new UnityDependencyResolver(container, resolver));
            AutoMapperBootstrap.AutomapperConfigure();

            return container;
        }

        private static IUnityContainer BuildUnityContainer()
        {
            var container = new UnityContainer();

            // register all your components with the container here
            // it is NOT necessary to register your controllers

            // e.g. container.RegisterType(); 

            RegisterTypes(container);

            return container;
        }

        public static void RegisterTypes(IUnityContainer container)
        {


            container.RegisterType<IDatabaseContext, DeploymentSettingsContext>();
        }
    }
}